#!/usr/bin/env python

import asyncio
from websockets.server import serve


async def handler_recv_msg(websocket):
    async for message in websocket:
        print(f"recv msg_len:{len(message)}")
        await websocket.send(message)


async def main():
    async with serve(handler_recv_msg, "localhost", 8899):
        await asyncio.Future()  # run forever


if __name__ == "__main__":
    asyncio.run(main())
